package com.cn.wanxi.util.servlet;

import com.cn.wanxi.util.model.*;
import com.cn.wanxi.util.service.impl.AboutNavService;
import com.cn.wanxi.util.service.impl.HeaderService;
import com.cn.wanxi.util.service.impl.RouteService;
import com.cn.wanxi.util.service.impl.SchoolContent2Service;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/contact")
public class ContactServlet extends HomeServletServlet {
    AboutNavService aboutNavService =new AboutNavService();
    HeaderService headerService =new HeaderService();
    SchoolContent2Service schoolContent2Service = new SchoolContent2Service();
    RouteService routeService =new RouteService();
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doGet(req, resp);
            //页面小导航
            List<AboutNavModel> aboutNavModels =aboutNavService.getaboutNavM();
            req.setAttribute("aboutNavModels",aboutNavModels);

            //内容标题
            List<CommunalTitle> communalTitles = headerService.getCommunalTitle();
            req.setAttribute("communalTitles",communalTitles);

//            联系方式
            List<SchoolContacModel> schoolContacModels =schoolContent2Service.getSchoolContacModel();
            req.setAttribute("schoolContacModels",schoolContacModels);

//            乘车路线
            List<RouteModel> routeModels =routeService.getRouteModel();
            req.setAttribute("routeModels",routeModels);
//            动画图片
            List<AnimationModel> animationModels =aboutNavService.getAnimationModel();
            req.setAttribute("animationModels",animationModels);
            gotoContac(req,resp);
        }

        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            gotoContac(req,resp);
        }
        private void gotoContac(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            req.getRequestDispatcher("/jsp/contact.jsp").forward(req,resp);
        }
}
